<?php
/**
 * Created by PhpStorm.
 * User: zhixuan
 * Date: 2019/11/19
 * Time: 23:11
 */

namespace app\common\model;


use app\common\traits\ModelTrait;
use think\Exception;


class Privilege extends BaseModel
{

    protected $pk = 'id';
    protected $name = 'privilege';

    use ModelTrait;

    public static function onBeforeDelete($data){

        $parentChannel = self::getCount(['parent_id'=>$data->id]);
        if($parentChannel>0){
            throw new Exception('该菜单有子菜单不能被删除');
        }
    }
}
